home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HPAVC
/
HPAVC CD-ROM.iso
/
MCASM.RAR
/
MC_ASM.EXE
/
WROX_ASM
/
CH13
/
TEST_UMB.ASM
< prev
Wrap
Assembly Source File
|
1994-11-14
|
3KB
|
87 lines
; This dummy program is a template for correct usage of upper memory
; using DOS functions and strategies.
; Demo program for ExpAsm Chapter 13 Memory Management under 1Mb
; written by Yuri Kisselev. Autumn 1991 - Summer 1994 ^Z Minsk.
.286
dosseg
.model small
.stack 100h
.data
ptr1 dw 0
save_str dw 0
flag_link db 0
.code
Start: ; starting address
mov ax,@data
mov ds,ax ; Load data segent
mov bx,ss
sub bx,ax
shl bx,4
cli
mov ss,ax ; Load new stack pointer
add sp,bx
sti
mov bx,sp
add bx,15 ; round up to next paragraph
shr bx,4
add ax,bx
mov bx,es
sub ax,bx
mov bx,ax
mov ah,4ah
int 21h ; Resize program memory block
jc resize_error
mov ax,5800h
int 21h ; Get allocation strategy
mov save_str,ax ; Save it
mov ax,5802h
int 21h ; Get upper-memory link
mov flag_link,al ; Save it
mov bx,80h ; BX = first_fit_high
mov ax,5801h
int 21h ; Set allocation strategy
jc bad_strategy ; CF = 1 if error
mov ax,5803h
mov bx,1 ; BX = link flag
int 21h ; Set upper-memory link
jc link_error ; CF = 1 if error
mov bx,256 ; BX = size of block
mov ah,48h
int 21h ; Allocate memory block
jc alloc_err ; CF = 1 if error
mov ptr1,ax
; play with block
; . . .
mov es,ptr1
mov ah,49h
int 21h ; Free memory block
jc free_error ; CF = 1if error
mov bx,save_str
mov ax,5801h
int 21h ; Restore allocation strategy
jc bad_strategy ; CF = 1 if error
mov ax,5803h
xor bx,bx
mov bl,flag_link
int 21h ; Restore flag link
jc link_error ; CF = 1 if error
xor al,al ; set zero termination code
resize_error:
alloc_err:
bad_strategy:
link_error:
free_error:
mov ah,4ch
int 21h ; Exit
end Start